package com.accp.vehiclecare.action.hzaction;


import com.accp.vehiclecare.biz.hzbiz.shopbiz;
import com.accp.vehiclecare.vo.hzvo.*;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/shop") // 命名空间
public class shopaction {
    @Autowired(required = false)
    private shopbiz biz;

    @GetMapping("{p}/{s}/{name}")
    public PageInfo<Commodity> queryPage(@PathVariable Integer p, @PathVariable Integer s,@PathVariable String  name) throws Exception {
        return biz.Showlist(p,s,name);
    }
    @DeleteMapping("del/{id}")
    public Map<String, Object> deletePersonById(@PathVariable Integer id) {
        biz.Delete(id);
        Map<String, Object> message = new HashMap<String, Object>();
        message.put("code", "200");
        message.put("msg", "ok");
        return message;
    }
    @GetMapping("list")
    public List<Countunit> queryPage2() throws Exception {
        return biz.showlist2();
    }
    @GetMapping("list2")
    public List<goodssource> queryPage3() throws Exception {
        return biz.showlist3();
    }
    @GetMapping("list3")
    public List<Commtype> queryPage4() throws Exception {
        return biz.showlist4();
    }
    @PostMapping("addsp")
    public Map<String, Object> addPerson2(@RequestBody Commodity commodity){
        biz.addsp(commodity);
        Map<String, Object> message = new HashMap<String, Object>();
        message.put("code", "200");
        message.put("msg", "ok");
        return message;
    }
}
